﻿@using QLNS
@{
    ViewBag.Title = "Frel";
    Layout = "~/Views/Shared/_Home.cshtml";

    List<QHGD> listQHGD = ViewBag.DSQHGD;
    CanBo cb = ViewBag.ChiTietCanBo;
    PhongBan pb = ViewBag.PhongBan;
    ChucVu cv = ViewBag.ChucVu;
    String tt = "";
    if (Convert.ToInt32(cb.TrangThai) == 1)
    {
        tt = "Đang làm việc";

    }
    if (Convert.ToInt32(cb.TrangThai) == 0)
    {
        tt = "Chuyển công tác";

    }
    if (Convert.ToInt32(cb.TrangThai) == 2)
    {
        tt = "Nghỉ";

    }
    
}
<link rel="stylesheet" href="@Url.Content("~/Content/jquery-ui.css")" />  
  <script src="@Url.Content("~/Scripts/jquery-ui1.js")" type="text/javascript"></script>
  <script>
      $(function () {
          $("#NgaySinh").datepicker();
          $("#NgaySinh").datepicker("option", "dateFormat", "dd/mm/yy");
          }
  </script>
<div>
<table width="100%" border="0" class="infoPerson"> 
  
  <tr>    
    <td rowspan="6" width="10%"><img width="120" height="130" src="@Url.Content("~/" + @cb.Image)" /></td>
    <td width="10%" class="title">Số hiệu cán bộ:</td>
    <td width="80%">@Html.Label("SoHieuCBCC", cb.SoHieuCBCC)</td>
    
  </tr>
  <tr>
  <td width="10%" class="title">Họ và tên:</td>
   <td width="80%" class="info">@Html.Label("Ho", cb.Ho) @Html.Label("Ten", cb.Ten) </td>
  </tr>
  <tr>
  <td width="10%" class="title">Phòng ban:</td>
   <td width="80%">@Html.Label("IDPhongBan", pb.TenPhongBan)  </td>
  </tr>
  <tr>
  <td width="10%" class="title">Chức vụ:</td>
   <td width="80%">@Html.Label("ChucVuHienTai", cv.Ten)  </td>
  </tr>
  <tr>
  <td width="10%" class="title">Ngày sinh:</td>
   <td width="80%">@Html.Label("NgaySinh", Convert.ToDateTime(cb.NgaySinh).ToString("dd/MM/yyyy")) </td>
  </tr>
  <tr>
  <td width="10%" class="title">Trạng thái:</td>
   <td width="80%">@Html.Label("TrangThai", tt)</td>
  </tr>
</table>
</div>
<div class="toolbar">
<ul>
    <li><input class="tbtnBack" type="button" value="Quay về" onclick="javascript:history.back()"/>
    </li>
     @{ if (Session["Quyen"].ToString() == "1")
        {
    <li><input class="tbtnAdd" type="button" value="Thêm mới" onclick="javascript:window.location='/Frel/Add/@cb.ID'"/>
    </li>}}
     <li><input class="tbtnReport" type="button" value="In" onclick="javascript:window.location='/aspFrm/frmQuanHeGiaDinh.aspx?id=@cb.ID'"/>
    </li>
</ul>
<div class="ttitle">Quan hệ gia đình</div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        // prepare the data
        var source =
            {
                datatype: "json",
                datafields: [
                     { name: 'ID' },
					 { name: 'QuanHe' },
					 { name: 'HoVaTen' },
					 { name: 'NamSinh' },
					 { name: 'QueQuan' },
					 { name: 'NgheNghiep' },
					 { name: 'ChucVu' },
                     { name: 'DonViCongTac' },
                     { name: 'DiaChi' },
                     { name: 'GhiChu' }
                ],
                id: 'ID',
                url: '/Frel/GetPagingGrid/@cb.ID/',
                root: 'Rows',
                sort: function () {
                    // update the grid and send a request to the server.
                    $("#jqxgridcontent").jqxGrid('updatebounddata', 'sort');
                }

            };

        var dataAdapter = new $.jqx.dataAdapter(source,
                {
                    downloadComplete: function (data) {
                        source.totalrecords = data.TotalRows;
                    }
                }
            );

        // initialize jqxGrid
        $("#jqxgridcontent").jqxGrid(
            {
                width: '100%',
                source: dataAdapter,
                theme: 'darkblue',
                autoheight: true,
                pageable: true,
                virtualmode: true,
                sortable: true,
                rendergridrows: function (params) {
                    return params.data;
                },
                ready: function () {
                    $("#jqxgridcontent").jqxGrid('hidecolumn', 'ID');
                     @{ if (Session["Quyen"].ToString() == "2")
                       {
                           @(new HtmlString("$('#jqxgridcontent').jqxGrid('hidecolumn', 'Delete');"))
                           @(new HtmlString("$('#jqxgridcontent').jqxGrid('hidecolumn', 'Edit');"))
                       }
                     }
                },
                columns:
                 [
                      { text: 'ID', editable: false, datafield: 'ID', width: 0 },
                      { text: 'Quan hệ', datafield: 'QuanHe', width: '10%' },
                      { text: 'Họ tên', datafield: 'HoVaTen', width: '10%' },
                      { text: 'Năm Sinh', datafield: 'NamSinh', width: '5%' },
                      { text: 'Quê quán', datafield: 'QueQuan', width: '10%' },
                      { text: 'Nghề nghiệp', datafield: 'NgheNghiep', width: '10%' },
                      { text: 'Chức vụ', datafield: 'ChucVu', width: '10%' },
                      { text: 'Đơn vị công tác', datafield: 'DonViCongTac', width: '10%' },
                      { text: 'Địa chỉ', datafield: 'DiaChi', width: '10%' },
                      { text: 'Ghi chú', datafield: 'GhiChu', width: '10%' },
                      { text: 'Delete', datafield: 'Delete', columntype: 'button', pinned: true, width: '10%',
                          cellsrenderer: function () {
                              return "Delete"
                          },

                          buttonclick: function (row) {
                              // open the popup window when the user clicks a button.
                              editrow = row;

                              var dataRecord = $("#jqxgridcontent").jqxGrid('getrowdata', editrow);
                               jqxConfirm.alert("Bạn có chắc muốn xóa người này ra khỏi danh sách quan hệ gia đình?");
                              $("#alert_button").click(function () 
                              {
                                            document.location.href = '/Frel/Delete/' + dataRecord.ID + '/';
                                            jqxAlert._hide();
                              });
                              


                          } 
                      },

                      { text: 'Edit', datafield: 'Edit', columntype: 'button', pinned: true, width: '5%', 
                                cellsrenderer: function () 
                      {
                          return "Edit"
                      },
                    
                      buttonclick: function (row) 
                          {
                              // open the popup window when the user clicks a button.
                              editrow = row;
                         
                              var dataRecord = $("#jqxgridcontent").jqxGrid('getrowdata', editrow);
                              document.location.href = '/Frel/Update/' + dataRecord.ID + '/';
                             
                          
                          }
                      }
              
                  ]
            });

    });
    </script>

<div id="jqxgridcontent"></div>

